class code2 {
    //方法一：排序+hash
    public List<List<String>> groupAnagrams(String[] strs) {
        List<List<String>> ret = new ArrayList<>();
        Map<String,List<String>> map = new HashMap<>();
        //把字母放入hash
        for(String s:strs) {
            char[] str = s.toCharArray();
            Arrays.sort(str);
            String key = String.valueOf(str);
            List<String> list = map.getOrDefault(key,new ArrayList<>());
            list.add(s);
            map.put(key,list);
        }
        //结果list统计到ret
        for(String key:map.keySet()) {
            ret.add(map.get(key));
        }
        return ret;
    }
}